unit PrijavaFrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxClasses, BaseFrm, StdCtrls, ExtCtrls, ImgList, StdActns, ActnList,
  cxStyles, cxGridBandedTableView, cxEdit, cxContainer, cxControls,
  cxInplaceContainer, cxVGrid, cxGraphics, cxEditRepositoryItems,
  cxDBEditRepository,
  DialogGridFrm,
  DB, DBClient, alBaseDataSet, MConnect;

type
  TfrmPrijava = class(TfrmDialogGrid)
    scnMain: TSharedConnection;
    cdsMain: TBaseDataSet;
    dtsrcMain: TDataSource;
    scnPoslovnoLeto: TSharedConnection;
    cdsPoslovnoLeto: TBaseDataSet;
    dtsrcPoslovnoLeto: TDataSource;
    scnPosta: TSharedConnection;
    cdsPosta: TBaseDataSet;
    dtsrcPosta: TDataSource;
    lblUporabniskoIme: TcxCategoryRow;
    edtUporabniskoIme: TcxEditorRow;
    lblGeslo: TcxCategoryRow;
    edtGeslo: TcxEditorRow;
    lblPodjetje: TcxCategoryRow;
    lkpcbPodjetje: TcxEditorRow;
    lblPoslovnoLeto: TcxCategoryRow;
    lkpcbPoslovnoLeto: TcxEditorRow;
    procedure OnEditValueChanged(Sender: TObject;
      ARowProperties: TcxCustomEditorRowProperties);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  protected
    procedure Deinitialize; override;
    procedure Initialize; override;
  public
    { Public declarations }
  end;

var
  frmPrijava: TfrmPrijava;

implementation

{$R *.dfm}

procedure TfrmPrijava.Deinitialize;
begin
  inherited;
  cdsPoslovnoLeto.Close;
  cdsPosta.Close;
  cdsMain.Close;
end;

procedure TfrmPrijava.FormShow(Sender: TObject);
begin
  inherited;
  cdsPoslovnoLeto.Params.ParamByName('PODJETJE_ID').Value :=
    cdsMain.FieldValues['ID'];
  cdsPoslovnoLeto.Open;
end;

procedure TfrmPrijava.Initialize;
begin
  inherited;
  cdsMain.Open;
  cdsPosta.Open;
end;

procedure TfrmPrijava.OnEditValueChanged(Sender: TObject;
  ARowProperties: TcxCustomEditorRowProperties);
begin
  inherited;
  if cdsMain.Active and (ARowProperties.Row = lkpcbPodjetje) then
  begin
    cdsPoslovnoLeto.Close;
    cdsPoslovnoLeto.Params.ParamByName('PODJETJE_ID').Value :=
      cdsMain.FieldValues['ID'];
    cdsPoslovnoLeto.Open;
  end;
end;

end.
